package com.ljfiction.book.MyView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ListView;

/**
 * Created by Android on 2017/10/9.
 */

public class ListviewMy extends ListView{
    public ListviewMy(Context context) {
        super(context);
    }

    public ListviewMy(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    int flag = 0;
    private float StartX,StartY,ScollX,ScollY;
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
//总是调用listview的touch事件处理
        onTouchEvent(ev);
        /*if(ev.getAction()==MotionEvent.ACTION_DOWN){
            StartX = ev.getX();
            StartY = ev.getY();
            return false;
        }
        if(ev.getAction()==MotionEvent.ACTION_MOVE){
            ScollX = ev.getX()-StartX;
            ScollY = ev.getY()-StartY;
//判断是横滑还是竖滑，竖滑的话拦截move事件和up事件（不拦截会由于listview和scrollview同时执行滑动卡顿）
            if(Math.abs(ScollX)<Math.abs(ScollY)){
                flag = 1;
                return true;
            }
            return false;
        }
        if(ev.getAction()==MotionEvent.ACTION_UP){
            if(flag==1){

                return true;
            }
            return false;
        }
        return super.onInterceptTouchEvent(ev);
    }*/
        return false;
    }
}
